import { useState } from 'react';
import { PaginationResponse } from '@datorama/akita';

import { makeFacade, RoomsFacade } from '@/facade/anchorFollowEntityFacade';
import { VISIBILITY_FILTER } from '@/models/commonType'; 
import { useObservable } from '@/utils/rxHelpers';
import { AnchorsItem } from '@/models/request/userReq';

export type FollowsHookTuple = [RoomsFacade, PaginationResponse<AnchorsItem>, VISIBILITY_FILTER];

//需要在页面用到的变量都在这里hook，主要用于简化页面调用逻辑和代码
export function useFollowsFacade(): FollowsHookTuple {
  const [roomsFacade] = useState(() => makeFacade());  

  const [filter] = useObservable(roomsFacade.filter$, VISIBILITY_FILTER.SHOW_ALL);

  const [pagination] = useObservable(roomsFacade.pagination$, {} as PaginationResponse<AnchorsItem>);

  return [roomsFacade, pagination, filter];
}
